MIT Scheme Reference

您所在的位置:网站首页 excuse memv MIT Scheme Reference

MIT Scheme Reference

#MIT Scheme Reference| 来源: 网络整理| 查看: 265

Go to the previous, next section.

Searching Lists

procedure+: list-search-positive list predicate

procedure+: list-search-negative list predicate

Returns the first element in list for which predicate is (respectively) true or false; returns #f if it doesn't find such an element. (This means that if predicate is true (false) for #f, it may be impossible to distinguish a successful result from an unsuccessful one.) Predicate must be a procedure of one argument.

procedure: memq object list

procedure: memv object list

procedure: member object list

These procedures return the first pair of list whose car is object; the returned pair is always one from which list is composed. If object does not occur in list, #f (n.b.: not the empty list) is returned. memq uses eq? to compare object with the elements of list, while memv uses eqv? and member uses equal?.(10)

(memq 'a '(a b c)) => (a b c) (memq 'b '(a b c)) => (b c) (memq 'a '(b c d)) => #f (memq (list 'a) '(b (a) c)) => #f (member (list 'a) '(b (a) c)) => ((a) c) (memq 101 '(100 101 102)) => unspecified (memv 101 '(100 101 102)) => (101 102)

procedure+: member-procedure predicate

Returns a procedure similar to memq, except that predicate, which must be an equivalence predicate, is used instead of eq?. This could be used to define memv as follows:

(define memv (member-procedure eqv?))

Go to the previous, next section.



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3